package sdfi.lee.Entity.base;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * This is an object that contains data related to the platform table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="platform"
 */

public abstract class BasePlatform  implements Serializable {

	public static String REF = "Platform";
	public static String PROP_PLATUSED = "platused";
	public static String PROP_PLATTOLL = "plattoll";
	public static String PROP_PLATNAME = "platname";
	public static String PROP_ID = "id";
	public static String PROP_PLATTOLLFMT = "plattollfmt";
	public static String PROP_PLATCOUNT = "platcount";
	

	// constructors
	public BasePlatform () {
		initialize();
	}

	/**
	 * Constructor for primary key
	 */
	public BasePlatform (java.lang.Integer id) {
		this.setId(id);
		initialize();
	}

	protected void initialize () {}



	private int hashCode = Integer.MIN_VALUE;

	// primary key
	private java.lang.Integer id;

	// fields
	private java.lang.String platname;
	private java.lang.Integer plattoll;
	private java.lang.Integer plattollfmt;
	private java.lang.Integer platcount;
	private java.lang.Integer platused;
	private java.lang.String platdescribe;
	private java.lang.String platPath;
	// collections
	private java.util.Set<sdfi.lee.Entity.Change> changes;



	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="identity"
     *  column="Id"
     */
	public java.lang.Integer getId () {
		return id;
	}

	/**
	 * Set the unique identifier of this class
	 * @param id the new ID
	 */
	public void setId (java.lang.Integer id) {
		this.id = id;
		this.hashCode = Integer.MIN_VALUE;
	}




	/**
	 * Return the value associated with the column: platname
	 */
	public java.lang.String getPlatname () {
		return platname;
	}

	/**
	 * Set the value related to the column: platname
	 * @param platname the platname value
	 */
	public void setPlatname (java.lang.String platname) {
		this.platname = platname;
	}



	/**
	 * Return the value associated with the column: plattoll
	 */
	public java.lang.Integer getPlattoll () {
		return plattoll;
	}

	/**
	 * Set the value related to the column: plattoll
	 * @param plattoll the plattoll value
	 */
	public void setPlattoll (java.lang.Integer plattoll) {
		this.plattoll = plattoll;
	}



	/**
	 * Return the value associated with the column: plattollfmt
	 */
	public java.lang.Integer getPlattollfmt () {
		return plattollfmt;
	}

	/**
	 * Set the value related to the column: plattollfmt
	 * @param plattollfmt the plattollfmt value
	 */
	public void setPlattollfmt (java.lang.Integer plattollfmt) {
		this.plattollfmt = plattollfmt;
	}



	/**
	 * Return the value associated with the column: platcount
	 */
	public java.lang.Integer getPlatcount () {
		return platcount;
	}

	/**
	 * Set the value related to the column: platcount
	 * @param platcount the platcount value
	 */
	public void setPlatcount (java.lang.Integer platcount) {
		this.platcount = platcount;
	}



	/**
	 * Return the value associated with the column: platused
	 */
	public java.lang.Integer getPlatused () {
		return platused;
	}

	/**
	 * Set the value related to the column: platused
	 * @param platused the platused value
	 */
	public void setPlatused (java.lang.Integer platused) {
		this.platused = platused;
	}



	/**
	 * Return the value associated with the column: changes
	 */
	public java.util.Set<sdfi.lee.Entity.Change> getChanges () {
		return changes;
	}

	/**
	 * Set the value related to the column: changes
	 * @param changes the changes value
	 */
	public void setChanges (java.util.Set<sdfi.lee.Entity.Change> changes) {
		this.changes = changes;
	}

	public void addTochanges (sdfi.lee.Entity.Change change) {
		if (null == getChanges()) setChanges(new java.util.TreeSet<sdfi.lee.Entity.Change>());
		getChanges().add(change);
	}




	public boolean equals (Object obj) {
		if (null == obj) return false;
		if (!(obj instanceof sdfi.lee.Entity.Platform)) return false;
		else {
			sdfi.lee.Entity.Platform platform = (sdfi.lee.Entity.Platform) obj;
			if (null == this.getId() || null == platform.getId()) return false;
			else return (this.getId().equals(platform.getId()));
		}
	}

	public int hashCode () {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getId()) return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}


	public String toString () {
		return super.toString();
	}

	public java.lang.String getPlatdescribe() {
		return platdescribe;
	}

	public void setPlatdescribe(java.lang.String platdescribe) {
		this.platdescribe = platdescribe;
	}

	public java.lang.String getPlatPath() {
		this.getPath(this.getPlatdescribe());
		return platPath;
	}

	public void setPlatPath(java.lang.String platPath) {
		this.platPath = platPath;
	}
	
	private void getPath(String source)
	{
		
		try
		{
			
			if(source!=null)
			{
			String regex="/project.+[jpg][gif]";
			Pattern pattern=Pattern.compile(regex);
			Matcher matcher=pattern.matcher(source);
			Pattern p=Pattern.compile(regex);
			Matcher m=p.matcher(source);
			if(m.find())
			{
				this.setPlatPath(m.group().replace("/project", ""));
				//System.out.println(m.group().replace("/project", ""));
			}
			}
			
	
		}
		catch(Exception ee)
		{
			System.out.println("Exception when get person pictrue");
			ee.printStackTrace();
		}
		
		
	}


}